package com.punch.system.controller;


import com.punch.common.dto.system.ActivityDTO;
import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.query.syste.ActivityQueryInfo;
import com.punch.common.vo.system.ActivityVO;
import com.punch.system.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 系统活动表 前端控制器
 * </p>
 *
 * @author wjj
 * @since 2020-12-14
 */
@RestController
@Api(value = "ActivityController", tags = "系统活动管理Controller")
public class ActivityController {

    @Resource
    private ActivityService activityService;


    /**
     * 活动列表
     *
     * @param queryInfo 查询条件
     * @return PageInfo<ActivityVO>
     */
    @GetMapping(value = "/activities", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "活动列表", notes = "活动列表", produces = "application/json")
    public Result<PageInfo<ActivityVO>> listActivity(@ModelAttribute ActivityQueryInfo queryInfo) {
        return Result.succeed(activityService.listActivity(queryInfo));
    }


    /**
     * 保存活动
     *
     * @param activityDTO 提交表单
     * @return id
     */
    @PostMapping(value = "/activity", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 保存活动", notes = " 保存活动", produces = "application/json")
    public Result<Integer> saveActivity(@RequestBody ActivityDTO activityDTO) {
        return Result.succeed(activityService.saveActivity(activityDTO));
    }

    /**
     * 修改活动
     *
     * @param activityDTO 提交表单
     * @return id
     */
    @PutMapping(value = "/activity", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改活动", notes = " 修改活动", produces = "application/json")
    public Result<Integer> updateActivity(@RequestBody ActivityDTO activityDTO) {
        return Result.succeed(activityService.updateActivity(activityDTO));
    }


    /**
     * 活动详情
     *
     * @param activityId activityId
     * @return ActivityVO
     */
    @GetMapping(value = "/activity/{activityId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "活动详情", notes = "活动详情", produces = "application/json")
    public Result<ActivityVO> getActivity(@PathVariable Integer activityId) {
        return Result.succeed(activityService.getActivity(activityId));
    }

    /**
     * 删除活动
     *
     * @param activityId activityId
     * @return id
     */
    @DeleteMapping(value = "/activity/{activityId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 删除活动", notes = " 删除活动", produces = "application/json")
    public Result<Integer> deleteActivity(@PathVariable Integer activityId) {
        return Result.succeed(activityService.deleteActivity(activityId));
    }


    /**
     * 修改活动状态
     *
     * @param activityId activityId
     * @param status   状态 0-不显示 1-显示
     * @return bannerId
     */
    @PutMapping(value = "/activity/{activityId}/status/{status}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改活动状态", notes = " 修改活动状态", produces = "application/json")
    public Result<Integer> updateActivityStatus(@PathVariable Integer activityId, @PathVariable Integer status) {
        return Result.succeed(activityService.updateActivityStatus(activityId, status));
    }
}
